/**
 * Created by Administrator on 2016/5/10.
 */
$(function(){
    /**
     @说明：超凡研究院--首页
     @作者：Daphne
     @时间：2016-5-10
     */
    //hover显示老师简介
    var   $mq_rt_jdTeacher = $('#mq_rt_jdTeacher');
    var   $mq_jdTeacher = $('#mq_jdTeacher');
    $mq_rt_jdTeacher.hover(function(){
        $mq_jdTeacher.stop().animate({ bottom : 0 },400);
    },function(){
        $mq_jdTeacher.stop().animate({ bottom : -98+'px' },300);
    });





    /**
     @说明：超凡研究院--IP资料
     @作者：Daphne
     @时间：2016-5-10
     */
    //研究院-IP-列表
    var $mq_IP_list = $('#mq_IP_list'),
        $mq_popup = $('#mq_popup');

    //弹出框弹出
    $mq_IP_list.on('click','li',function(){
        $mq_popup.removeClass('f-dhid');
        $('html,body').addClass('f-overflow-y');
    });
    //点击关闭按钮-关闭弹出框
    $mq_popup.on('click','.zq-close',function(){
        $mq_popup.addClass('f-dhid');
        $('html,body').removeClass('f-overflow-y');
    });





    /**
     @说明：超凡研究院--超凡活动
     @作者：Daphne
     @时间：2016-5-10
     */
    //超凡活动-手风琴效果
    var $mq_accordion = $('#mq_accordion');
    $mq_accordion.on('mouseover','li',function(){
        $(this).addClass('zq-act').stop(true).animate({'width' : '785px'},200)
            .siblings().removeClass('zq-act').stop(true).animate({'width' : '100px'},200);
    });





    /**
     @说明：超凡研究院--超凡活动--详情“我要报名”
     @作者：Daphne
     @时间：2016-5-10
     */
    var CHOFN = (function(chofn){
        var $popEnter = $('#mq_popup_enter'),
            $body =  $('html,body'),
            addBox =  $('#add_person_text').find('.mq_add_main'),
            addText = addBox.html(),
            personCount,
            persons = [], //报名人信息
            temp2;
        //弹出报名表
        chofn.tabPop = function(){
            $popEnter.removeClass('f-dhid');
            $('.mq_success-pupOuter').addClass('f-dhid');
            $body.addClass('f-overflow-y');
        };
        //默认填写三个人
        chofn.defaultPersonBox = function(){
            var flag= addBox.find('ul').length;
            for(var i = flag; i>1; i--){
                if(i > 1){
                    addBox.find('ul').last().remove();
                    if(i == 2){
                        addBox.find('.zq-out').addClass('f-dhid');
                    }
                }
            }
        };
        //关闭报名表
        chofn.tabClose = function(dom){
            $popEnter.addClass('f-dhid');
            $body.removeClass('f-overflow-y');
            var _this = $(dom),
                _form = _this.siblings('form');
            _form.find('.mq_text').find('input[type=text]').val('');
            _form.find('.mq_text').find('input[type=radio]').prop('checked',false);
            chofn.defaultPersonBox();
        };
        //成功弹框关闭报名表
        chofn.subTabClose = function(dom){
            $popEnter.addClass('f-dhid');
            $body.removeClass('f-overflow-y');
            var _this = $(dom),
                _box = _this.parents('.mq_success-pupOuter'),
                _form = _box.siblings('#mq_popup_enter');
            _form.find('.mq_text').find('input[type=text]').val('');
            _form.find('.mq_text').find('input[type=radio]').prop('checked',false);
            _box.addClass('f-dhid');
            chofn.defaultPersonBox();
        };
        //添加人员
        chofn.addPerson = function(){
            personCount =addBox.find('ul').length;
            if(personCount>9){
                alert('最多只能报名10人哦！');
                return;
            }
            addBox.append(addText);
            addBox.find('.zq-out').removeClass('f-dhid');
        };
        //减少人员
        chofn.reducePerson = function(dom){
            var _this = $(dom);
            temp2 = addBox.find('ul').length;
            if(temp2 > 1){
                _this.parent().remove();
                if(temp2 == 2){
                    addBox.find('.zq-out').addClass('f-dhid');
                }
            }
        };
        //提交报名信息
        chofn.subSignUp = function(dom){
            persons = []; //报名人员信息
            var _this = $(dom),
                _from = _this.parents('form'),
                companyName = _from.find('input[name="company_name"]').val(), //公司的名称
                companyArea = _from.find('input[name="company_area"]').val(), //公司的地址
                companyType = _from.find('input[type="radio"]:checked').val(), //公司的性质
                _ul = addBox.find('ul'),
                addPersonInput = addBox.find('input'),
                personNum = _ul.length; //判断公司报名人员数量
            if(companyName == ''||companyName == null){
                alert('请输入公司/机构全称！');
                return false;
            }
            if(companyArea == ''||companyArea == null){
                alert('请输入公司/机构所在地址！');
                return false;
            }

            var  email = _from.find('input[name="email[]"]').val();
            if(isEmail(email) == false){
                    alert('邮箱格式不正确,请从新输入！');
                return;
            }

            for(var i = 0,len = addPersonInput.length; i < len; i++){
                if(addPersonInput.eq(i).val() == ''||addPersonInput.eq(i).val() == null){
                    alert('请输全公司/机构报名人员信息！');
                    return;
                }
            }

            if(companyType == ''||companyType == null){
                alert('请选择公司的性质');
                return false;
            }
            $('#mq_enter_form').submit();
            _from.parents('#mq_popup_enter').addClass('f-dhid').siblings('.mq_success-pupOuter').removeClass('f-dhid');
            return true;
        };
        return chofn;
    }(CHOFN || {}));
    window.CHOFN = CHOFN;
});

function setAcademyList(subtype){
    $('#mq_nav_theme li').each(function(index,element){
        zqclass = $(this).attr('class');
        if( zqclass ){
            type = $(this).data('type');
            if(type=='最新'){
                setAcadSubList('rows',subtype,'loading');
            }else if(type=='专利'){
                setAcadSubList('patent',subtype,'patentsload');
            }else if(type=='商标'){
                setAcadSubList('brands',subtype,'brandsload');
            }else if(type=='版权'){
                setAcadSubList('copyrights',subtype,'copyrightsload');
            }else if(type=='互联网'){
                setAcadSubList('networks',subtype,'networkload');
            }else if(type=='产业'){
                setAcadSubList('domains',subtype,'domainsload');
            }else if(type=='国际'){
                setAcadSubList('internationals',subtype,'internationalsload');
            }
        }
    });
}
function setAcadSubList(id,subtype,type)
{
    var search = $('#search').find('input').val();
    var   url 	= "/academy/"+type+"/?page=1&direction="+subtype+"&rands="+getRand()+"&title="+search;
	num = getTyepNum(type);
	$('#'+id+' .listtr_'+num).remove();
	getAjax(url,num,1);
}
function getSubTyepName(){
	 str = '';
	$('#mq_new_type li').each(function(index, element) {
        zqclass = $(this).attr('class');
		if(zqclass){
			str = $.trim($(this).find('.mq-list4-txt').find('p').html());
		}
    });
	return 	str;
			
}


